﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CommonHelper
{
    public static class BaseRandom
    {
        private static string RandomString { set; get; } = "0123456789ABCDEFGHIJKMLNOPQRSTUVWXYZ";
        private static int RandomLength { set; get; }

        #region  产生随机字符
        /// <summary>
        /// 产生随机字符
        /// </summary>
        /// <returns>字符串</returns>
        public static string GetRandomString()
        {
            return GetRandomString(RandomLength);
        }

        public static string GetRandomString(int stringLength)
        {
            string returnValue = string.Empty;
            for (int i = 0; i < stringLength; i++)
            {
                int r =new Random().Next(0, RandomString.Length - 1);
                returnValue += RandomString[r];
            }
            return returnValue;
        }

        #endregion
    }
}
